package ast;

import mem.interfaces.IMem;
import environnement.interfaces.IEnv;
import ast.interfaces.IAST;
import ast.interfaces.IASTplus;

public class ASTplus implements IASTplus{
	private IAST op1;
	private IAST op2;
	
	public ASTplus(IAST op1,IAST op2){
		this.op1 = op1;
		this.op2 = op2;
	}

	public IAST getOp1() {
		return op1;
	}

	public void setOp1(IAST op1) {
		this.op1 = op1;
	}

	public IAST getOp2() {
		return op2;
	}

	public void setOp2(IAST op2) {
		this.op2 = op2;
	}

	@Override
	public Float eval(IAST ast, IEnv e, IMem m) {
		return ((Float)getOp1().eval(ast, e, m)) + ((Float)getOp2().eval(ast, e, m));
	}

	@Override
	public String toTreeString(String ident,IEnv env,IMem mem) {
		return getOp1().toTreeString(ident,env,mem) + '+' + getOp2().toTreeString(ident,env,mem);
	}
	
	
}
